#include <REGX52.H>
#include <INTRINS.H>

void Delay1ms(int xms)		//@12.000MHz
{
	unsigned char i, j;

	while(xms)
	{
			i = 2;
			j = 239;
			do
			{
				while (--j);
			} while (--i);
			xms--;
	}
}

int main()
{
	// 1111 1110 -> ~0000 0001
	// 1111 1101 -> ~0000 0010
	int n = 1;
	int cnt = 0;
	while(1)
	{
		P2 = ~n;
		// 0000 0010
		n = n << 1;
		Delay1ms(500);
		cnt++;
		if(cnt == 8)
		{
			cnt = 0;
			n = 1;
		}
	}
	return 0;
}